



const util = require('../../utils/util.js')
Page({
  data : {
    startYear:'',
    endYear :'',
    serie:'',
    category:'',
    cargos:[]
  },
  onLoad(option){
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    this.setData({
      startYear : option.startYear,
      endYear : option.endYear,
      serie : option.serie,
      category : option.category
    })
    var that = this;
    wx.request({
      url: util.http+"cargos/",
      data:{
        series : that.data.serie,
        start_year : that.data.startYear,
        end_year : that.data.endYear,
        category : that.data.category
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        that.setData({
          cargos: res.data.results
        })
      },
      complete: function (res) {
        wx.hideLoading();
        if (res == null || res.data == null) {
          console.error('网络请求失败');
        }
      }
    })  
  },
  clickImg : function(e){
      var id = e.target.dataset.id,
          title = e.target.dataset.title,
          link = '../cargo-detail/cargo-detail?id=' + id + '&title=' + title;
      wx.navigateTo({
        url: link
      })
  }
})